//
//  WhzSortView.m
//  WhzMT
//
//  Created by whz on 16/12/11.
//  Copyright © 2016年 whz. All rights reserved.
//

#import "WhzSortView.h"
#import "Header.h"

@interface WhzSortView ()

/** 排序的按钮*/
@property(nonatomic, strong)UIButton *btnSort;

/** 排序的文字1-排序*/
@property(nonatomic, strong)UILabel *labelSort1;

/** 排序的文字2-默认排序*/
@property(nonatomic, strong)UILabel *labelSort2;

@end

@implementation WhzSortView

- (instancetype)init {

    if (self = [super init]) {
        
        [self setupUI];
    }
    return self;
}

#pragma mark - 初始胡UI

- (void)setupUI {

    self.frame = CGRectMake(0, 0, 170, 40);
    
    self.btnSort = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.btnSort setImage:[UIImage imageNamed:@"icon_sort"] forState:UIControlStateNormal];
    [self.btnSort setImage:[UIImage imageNamed:@"icon_sort_highlighted"] forState:UIControlStateHighlighted];
    self.btnSort.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    [self addSubview:self.btnSort];
    [self.btnSort mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    [_btnSort addTarget:self action:@selector(btnClickSort) forControlEvents:UIControlEventTouchUpInside];
    
    self.labelSort1.text = @"排序";
    [self addSubview:self.labelSort1];
    [self.labelSort1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(40);
        make.top.equalTo(self);
        make.height.mas_equalTo(self.bounds.size.height * 0.5);
    }];
    
    self.labelSort2.text = @"默认排序";
    [self addSubview:self.labelSort2];
    [self.labelSort2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(40);
        make.top.equalTo(self.labelSort1.mas_bottom).offset(0);
        make.height.mas_equalTo(self.bounds.size.height * 0.5);
    }];
}

#pragma mark - 事件监听

- (void)btnClickSort {

    // 生成Action-Target事件
    [self sendActionsForControlEvents:UIControlEventTouchUpInside];
}

#pragma mark - 懒加载

- (UIButton *)btnSort {

    if (_btnSort == nil) {
        
        _btnSort = [[UIButton alloc] init];
    }
    return _btnSort;
}

- (UILabel *)labelSort1 {

    if (_labelSort1 == nil) {
        
        _labelSort1 = [[UILabel alloc] init];
    }
    return _labelSort1;
}

- (UILabel *)labelSort2 {

    if (_labelSort2 == nil) {
        
        _labelSort2 = [[UILabel alloc] init];
    }
    return _labelSort2;
}

@end
